<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<html>
<head>
    <title>资讯详情</title>

    <link rel="stylesheet" href="${ctx}/static/styles/news/newsdetail.css" type="text/css">
</head>

<body>
<div class="news-main">
    <div class="container row">
        <div class="col-lg-8 news-detail">
            <div class="news-header">
                <div class="news-back">
                    <a href="${ctx}/infor/index">< 返回互动首页</a>
                </div>
                <div class="news-title">
                    ${infor.title}
                </div>
                <div class="news-info">
                    <span>作者：${infor.author.name}</span>
                    <span>发布时间：<fmt:formatDate value="${infor.publishDate}" type="date" dateStyle="long"/></span>

                </div>
            </div>
            <div class="news-body">
                ${infor.content}
            </div>
            <%--<div class="comment-box">
                <c:forEach items="${infor.comments}" var="comment">
                    <div class="comment">
                        <span>${comment.author.name}</span>
                        <span><fmt:formatDate value="${comment.publishDate}" type="date" dateStyle="long"/></span>
                        <br/>
                        <span> ${comment.content}</span>
                    </div>
                </c:forEach>
            </div>--%>
            <div class="comment-box">
                <div class="comment-title">热门评论</div>
                <div id="comment-list">
                    <c:forEach items="${commentPage.content}" var="comment">
                        <div class="comment-item" data-uid="${comment.author.id}">
                            <div class="comment-header">
                                <span class="comment-author">${comment.author.name}</span>
                                <span class="comment-time"><fmt:formatDate value="${comment.publishDate}" type="date" dateStyle="long"/></span>
                            </div>
                            <div class="comment-content"> ${comment.content}</div>
                        </div>
                    </c:forEach>
                </div>
                <tags:pagination page="${commentPage}" paginationSize="5"/>
                <form action="${ctx}/cmt/for/${infor.id}" method="post" id="comment-form">
                    <label class="comment-area-title">发表评论</label>
                    <input type="hidden" name="targetUid" value="3">
                    <textarea name="content" rows="5"></textarea>
                    <button type="submit" class="pull-right">回复</button>
                </form>
            </div>
        </div>
        <div class="news-aside">
            <div class="news-aside-main">
                <div class="news-aside-header">
                    最新更新
                </div>
                <ul class="news-aside-list">
                    <c:forEach items="${infors}" var="infor">
                        <li class="news-aside-item">
                            <span class="news-time"><fmt:formatDate value="${infor.publishDate}" type="date" dateStyle="default"/></span>
                            <a class="news-aside-title" href="#">${infor.title}</a>
                        </li>
                    </c:forEach>

                </ul>
            </div>

        </div>
    </div>
</div>

<script src="${ctx}/static/js/jquery.form.js" type="text/javascript"></script>
<script>
    $("#comment-form").ajaxForm({
        success:function (data) {
            console.log(data);
        }
    });
</script>
</body>
</html>
